package Oop02;

public class Oop02 {
    public static void main(String[] args) {
        //Object > String
        //Object > Person > Teacher
        //Object > Person > Student
        //System.out.println(X instanceof Y); 能否编译通过 ， 看 X 和 Y 是否存在父子关系
        /* Object object = new Student();

        System.out.println(object instanceof Student);//true
        System.out.println(object instanceof Person);//true
        System.out.println(object instanceof Object);//true
        System.out.println(object instanceof Teacher);//false
        System.out.println(object instanceof String);//false
        System.out.println("________________");
        Person person = new Student();

        System.out.println(person instanceof Student);//true
        System.out.println(person instanceof Person);//true
        System.out.println(person instanceof Object);//true
        System.out.println(person instanceof Teacher);//false
        System.out.println("________________");
        Student student = new Student();

        System.out.println(student instanceof Student);//true
        System.out.println(student instanceof Person);//true
        System.out.println(student instanceof Object);//true
//        System.out.println(student instanceof Teacher);//编译报错

         */
        //类型之间的转化
        Person obj = new Student();//由低向高转
        //
        Student obj1 = (Student)obj;
        //将 obj 转化为 Student 类型 ， 我们就可以使用 Student 的方法了
        ((Student)obj).go();

        /*总结
        1. 父类的引用指向子类的对象
        2. 把子类转换为父类 ， 向上转型
        3. 把父类转换为子类 ， 向下转型， 但是可能会丢失一些自己本来的一些方法

        * */

    }
}
